#Towers of hanoi, iterative version

x = 1
n = 25 #number of discs


while (x < (1 << n)):
    frompole = (x&x-1)%3
    topole = ((x|x-1)+1)%3
    x = x + 1

print
print frompole
print topole
print x-1
print
